<?php
/**
 * 基础类
 * @author Administrator
 *
 */
class Base 
{
	public $sqlNew;
	public $webpath;
	public $slash = DIRECTORY_SEPARATOR;
	public $toosNew;
	public $tableNew;
	public function __construct()	{
		session_start();
		set_time_limit(0) ;
		$this->webpath=DIRECTORY.$this->slash;
	}
	//数据库
	public function sql(){
		if (empty($this->sqlNew)){
			$this->sqlNew = new sql();
		}
		return $this->sqlNew;
	}
	//工具
	public function toos(){
		
		if (empty($this->toosNew)){
			$this->toosNew = new toos();
		}
		return $this->toosNew;
	}
	/**
	 * 分页
	 * @param unknown $table
	 * @param unknown $page
	 * @param string $where
	 * @param string $order
	 * @return string
	 */
	public function paging($table,$pages,$where="",$order=""){
		$count = $this->sql()->onedata($table,"count(*)  ",$where);
		$page = new page($count[0],$pages);
		$limit[0]= $page->which;
		$limit[1]=$pages;
		$data['list'] = $this->sql()->datalist($table, " * ", $where.$order,$limit);
		$data['page']=$page->returnPage("?".$this->toos()->combinationGet('page')."&page=");
		return $data;
	}
}
?>